﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zor_DAL;
using Zor_Modes;
using Zor_Tools;
namespace Zor_Bll
{
    public class Zor_CertificateRecord_Bll<T> where T : class
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="TotalCount">返回值</param>
        /// <returns></returns>
        public static List<T> GetPageList(dynamic Model, int index, out int TotalCount,string where)
        {
            var sqlSurch = string.Empty;
            if (Model.CertificateNumber != null)
            {
                sqlSurch += " CertificateNumber = '" + Model.CertificateNumber + "' and ";
            }
            if (Model.CRState != null && Model.CRState != "全部")
            {
                sqlSurch += " CRState = '" + Model.CRState + "' and ";
            }
            sqlSurch += " Dt_ParentId = " + RequestSession.GetSessionUser().DT_Id + " ";
            return PagerHelp<T>.GetPagerList(index, "V_Zor_CertificateRecord", "CertificateNumber", out TotalCount, sqlSurch);
        }

        /// <summary>
        /// 完税证作废
        /// </summary>
        /// <param name="id">选中完税证作废id</param>
        /// /// <param name="AcceptanceId">选中受理单id</param>
        /// /// <param name="PtId">选中缴税管理id</param>
        /// <returns></returns>
        public static BaseAnswer CertificateCancel(int id, int AcceptanceId, int PtId, int CRID)
        {
            BaseAnswer bar = Zor_CertificateRecord_DAL<T>.CertificateCancel(id, AcceptanceId, PtId, CRID);
            if (bar.AnswerType != BaseAnswer.Answers.Error)
                bar.AnswerMeg = bar.AnswerType == BaseAnswer.Answers.Succee ? "完税证作废成功！" : "完税证作废失败，请重试！";
            return bar;
        }
    }
}
